<?
//////////////////////////////////////////////////////////////////////////////////////////
// TOPO PERMANENTE																		//
require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/_includes/config.php");	//
require_once(SAS_PATH . "_includes/seguranca.php");										//
//////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////
// SETA OS VALORES DA BUSCA
$campos_busca = array('nm_usua');
func_busca_variaveis($campos_busca);
///////////////////////////////////////

if ($nm_usua)
{
	$sql_where .= ($sql_where ? " AND" : "") . " a.nm_usua LIKE ('%".$nm_usua."%') ";
}

if ($sql_where)
{
	$sql_where = " WHERE " . $sql_where;
}

?>
<script language="JavaScript" type="text/javascript">
function buscaControl()
{
	busca = document.getElementById("buscaRegistros");
	busca.value = (busca.value == "1" ? "0" : "1");
	formTableOculto = document.getElementById("formBuscaCampos");
	formTableOculto.style.display = (busca.value == "1" ? "block" : "none");
}
</script>

<form name="formBusca" method="get" action="">
  <table border="0" cellspacing="0" cellpadding="0" class="formCampos">
    <tr>
      <td><table border="0" cellspacing="0" cellpadding="0">
          <tr class="formCampos">
            <td class="formLabel"><input name="buscaRegistros" id="buscaRegistros" type="hidden" value="0" />
              <a href="javascript:void(0)" onClick="buscaControl()"><img src="imagens/botoes/busca.gif" alt="Clique para procurar registros" width="62" height="21" border="0"></a> </td>
          </tr>
        </table></td>
    </tr>
    <tr>
      <td id="formBuscaCampos" style="display:none"><table border="0" cellpadding="0" cellspacing="0" class="formCampos">
          <tr>
            <td class="formLabel"> Nome: </td>
            <td><input name="nm_usua" type="text" class="formInput formGrande" maxlength="80" id="nm_usua" value="<?=$nm_usua?>" />            </td>
          </tr>
          <tr>
            <td colspan="2" align="right" class="formLabel"><input type="submit" class="formButton" id="formButtonOk" value="OK" />            </td>
          </tr>
        </table></td>
    </tr>
  </table>
</form>
<?
require_once(SAS_PATH . "_includes/classes/paginacao.class.php");

$sql = "SELECT
			a.cd_usua, 
			a.nm_usua,
			b.nm_grupo
		FROM
			seg_usua a
		INNER JOIN
			seg_grupo b
		ON 
			a.cd_grupo = b.cd_grupo

		" . $sql_where . "
		ORDER BY
			nm_usua";
		
$pg = new paginacao($db, $sql);
$pg->consulta;

$pg->cabecalho = '
  <tr class="linhaHeader">
	<td width="1%"></td>
	<td width="35%">Nome<? print_seta_ordem()?></td>
	<td>Grupo</td>
	<td></td>
  </tr>
  ';

$pg->linha = '
  <tr class="linha<?=$c&1?>" onMouseOver="this.className=\'linhaOver\'" onMouseOut="this.className=\'linha<?=$c++&1?>\'" > 
	<td></td>
	<td><?=$lst[\'nm_usua\']?></td>
	<td><?=$lst[\'nm_grupo\']?></td>
	<td align="right" nowrap="nowrap"><? print_consultar(array("cd_usua"=>$lst[\'cd_usua\']))?> <?print_alterar(array("cd_usua"=>$lst[\'cd_usua\']))?></td>
  </tr>
  ';

$pg->resultado();


///////////////////////////////////////
// SETA OS VALORES DA BUSCA
func_busca_campos($campos_busca);
///////////////////////////////////////
?>
